import { AnimatorStateLogic } from "db://app-game/libs/animator/core/AnimatorStateLogic";
import { Role } from "../../../Role";
import { AnimationEventHandler } from "../AnimationEventHandler";
import AnimatorState from "db://app-game/libs/animator/core/AnimatorState";
import AnimatorParams from "db://app-game/libs/animator/core/AnimatorParams";
import { RoleSkillType } from "../../../Role.type";

export const skills = {
  /** 屏息 */
  [RoleSkillType.BreathHold]: "bxidle",
  /** 翻滚 */
  [RoleSkillType.Roll]: "fangun",
};
/** 上半身攻击动画逻辑 */
export class RoleUpperStateSkills<T> extends AnimatorStateLogic {
  /** 角色 */
  private role: Role;
  private anim: AnimationEventHandler<T>;

  public constructor(role: Role, anim: AnimationEventHandler<T>) {
    super();
    this.role = role;
    this.anim = anim;
  }

  public onEntry(state: AnimatorState, param: AnimatorParams): void {
    const skillType = param.getNumber("skillType");
    if (skills[skillType]) {
      this.anim.playAnimation(skills[skillType], false);
    }
  }
  public onUpdate(): void {}
  public onExit(): void {}
}
